if($(".login")){
    $(".loginbox").mouseover(() =>{
        $(".top-hover").css("display","block");
    });
    $(".loginbox").mouseout(() =>{
        if($(".top-hover").mouseover){
            $(".top-hover").css("display","block");
        }
        if($(".top-hover").mouseout){
            $(".top-hover").css("display","none");
        }
    });
};

//hot-search开关门
$(".top-search").click(() =>{
        $(".top-search-list").slideDown(1000),() =>{
            $(".top-search-list").css("display","block");
        };
})
$(".top-search").blur(() =>{
    $(".top-search-list").fadeOut(1000),() =>{
        $(".top-search-list").css("display","none");
    };
})
//头部导航开关门
$(".all-class").mouseover(() =>{
    $(".i-arr").css("background-position","-66px -2px");
    $(".top-submenu").css("display","block");
})
$(".all-class").mouseout(() =>{
    $(".i-arr").css("background-position","-100px -2px");
    $(".top-submenu").css("display","none");
});
$(".top-submenu").mouseover(() =>{
    $(".top-submenu").css("display","block");
})
$(".top-submenu").mouseout(() =>{
    $(".top-submenu").css("display","none");
})
//header滚动监听
$(window).scroll(()=>{
    if($(window).scrollTop()>440){
            $(".top-scroll").css("width",$(window).width()).css("display","block");
            $(".header_foot1").css("display","block").css("width",$(window).width());
        }else{
            $(".top-scroll").css("display","none");
            $(".header_foot1").css("display","none");
        }
        
})
//登录
$(".unlogin>a:eq(0)").click(e =>{
    e = window.event;
    target = e.srcElement;
    $("article").css("display","block");
})
$(".unlogin>a:eq(1)").click(e =>{
    e = window.event;
    target = e.srcElement;
    $("article").css("display","block");
})
//关闭登录
$(".milo_btn_close").click(() =>{
    $("article").css("display","none");
})
//快速登录
$(".tips1").click(() =>{
    $(".qlogin").css("display","block");
    $(".web_qr_login").css("display","none");
    $(".face>img").attr("src","../img/"+localStorage.img);
    $(".nick").html(localStorage.name);
})
$(".tips2").click(() =>{
    $(".qlogin").css("display","none");
    $(".web_qr_login").css("display","block");
})
//登录提交
$(".submit").click(() =>{
    let uname = $(".inputstyle:eq(0)").val();
    let upwd = $(".inputstyle:eq(1)").val();
    console.log("111");
})
//登录成功界面
if(sessionStorage.uname){
    if(sessionStorage.uname != ""){
        $(".unlogin").css("display","none");
        $(".login").css("display","block");
        $(".hdname").html(sessionStorage.uname);
        $(".hdimg>img:eq(0)").attr("src","../img/"+sessionStorage.img);
        $(".hdimg>img:eq(1)").attr("src","../img/"+sessionStorage.img);
    }else{
        $(".unlogin").css("display","block");
        $(".login").css("display","none");
    }
}else{
    $(".unlogin").css("display","block");
    $(".login").css("display","none");
}
//退出登录
$(".quit-link").click(() =>{
    $(".unlogin").css("display","block");
    $(".login").css("display","none");
    sessionStorage.uname ="";
    sessionStorage.uid ="";
    history.go(0);
})
//点击头像快速登录
$(".img_out_focus").click(() =>{
    let name = localStorage.name;
    let img = localStorage.img;
    $.getJSON("http://192.168.20.41/daojucheng-juchengpin/project/php/sever.php?key=?",`hide=speed&name=${name}&img=${img}`,data =>{
        let arr = data.split(";");
        localStorage.img = arr[0],
        sessionStorage.img = arr[0],
        localStorage.name = arr[1],
        sessionStorage.uname = arr[1],
        sessionStorage.uid = arr[2];
        history.go(0);
    },"JSON")
})

// 购物车数量
console.log($(".cart-num:eq(0)"))
$.get("../php/jc_person.php","hide=getShopcar",data=>{
    console.log(data)
    let count=0;
    data.forEach(obj=>{
        if(sessionStorage.uid==obj.userid){
            count+=parseInt(obj.count);
        }
    })
    console.log(count)
    $(".cart-num:eq(0)").html(count)
},"JSON")